package com.allianz.webapps.controllers;

import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="wechat")
public class WechatRecordController {

	public static int shareCount = 0;
	
	@RequestMapping(value="getShareInfo")
	@ResponseBody
	public Map<String, String> getShareInfo(){
		Map<String, String> map = new HashMap<String, String>();
		map.put("shareCount", String.valueOf(shareCount));
		
		InetAddress ia=null;
        try {
            ia = InetAddress.getLocalHost();
             
            String localname=ia.getHostName();
            String localip=ia.getHostAddress();
            map.put("serverIp", localip);
            map.put("serverName", localname);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
		return map;
	}
	
	@RequestMapping(value="setShareZero")
	@ResponseBody
	public void setShareZero(){
		shareCount = 0;
	}
	
	@RequestMapping(value="addShareCount")
	@ResponseBody
	public void addShareCount(){
		shareCount++;
	}
	
}
